package com.szrt.java.day20161222.wu.demo07;

import org.junit.Test;

public class MathTest {
	
	/**
	 * = 赋值号
	 * == 等于
	 */
	@Test
	public void equal01(){
		int a = 22;
		int b = 22;
		System.out.println(a==b);
	}
	
	@Test
	public void equal02(){
		//变量可以多次赋值
		int money = 5000;
		money = money + 1000;
		System.out.println(money);
	}
	
	@Test
	public void equal03(){
		//变量在一定的区域内部不用重复定义（在中国是一夫一妻制）
		int money = 5000;
//		int money = 4000;
		System.out.println(money);
	}
	
	/** int a = 10; int b = a++;/b = ++a;
	 * 共同点：a = 11
	 * 区分：   b等于多少看 = 后跟的第一个字符
	 * 	= 后跟 a  ：先取后加   b = 10;
	 *  = 后跟++	: 先加后取   b = 11;
	 */
	@Test
	public void addadd01(){
		int a = 10;
		int b = a++;
//		int b = a ; a = a+1;
		System.out.println("a = "+a);
		System.out.println("b = "+b);
	}
	
	@Test
	public void addadd02(){
		int a = 10;
		int b = ++a;
//		int b = a+1 ; a = a+1;
		System.out.println("a = "+a);
		System.out.println("b = "+b);
	}
	
	//--------------------------------
	@Test
	public void subsub01(){
		int a = 10;
		int b = --a;
		System.out.println("b = "+b);
		System.out.println("a = "+a);
	}
	
	@Test
	public void addsub(){
		int a = 10;		//a = 10;
		int b = 10;		//b = 10
		int c = ++a;	//c = 11 ; a = 11;
		int d = b--;	//d = 10 ; b = 9;
		int e = c++;	//e = 11 ; c = 12;
		int f = ++d; 	//f = 11 ; d = 11
		System.out.println(e+"  "+ f);
	}
	
	//---------------------------------
	@Test
	public void sum01(){
		int a = 10;
		int b = 20;
		int sum = a+b;
		sum = sum+1;
		System.out.println(sum);
	}
	
	@Test
	public void sum02(){
		int a = 10;
		int b = 20;
		int sum =a+b;		//sum = 10+20 =30;
		sum = sum++;		//sum = 30;
		System.out.println(sum);
	}
	
	/**
	 * 重点 区分除法 和 求模
	 */
	@Test
	public void mod(){
		/**
		 *  /：代表除法，结果取结果的整数部分  a = 9;
		 */
		int a = 49/5;
		System.out.println(a);
		
		/**
		 *   %:代表求模，结果取整个结果的余数部分 b = 4;
		 */
		int b = 49%5;
		System.out.println(b);
	}

}
